<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: xajax.tag_words.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: peter $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$xajax->registerFunction('searchDB');

function searchDB($word, $tid) {
	global $db;
	
	$ajax = new xajaxResponse();

	$getTags = $db->db_query("SELECT
								tag
							FROM
								".TABLE_TAG_TO_PRODUCT."
							WHERE
								tag LIKE '%".$word."%'
							GROUP BY
								tag");

	if($getTags->_numOfRows > 0 && !empty($word)) {
		while(!$getTags->EOF) { $i++;
			$class = '';
			if($i % 2)
				$class = ' dunkel';
			$tag = str_ireplace($word, '<span style="color:#b20000">'.$word.'</span>', $getTags->fields['tag']);
			$list .= '<div class="tag_list_treffer'.$class.'" onclick="$(\'#tag_'.$tid.'\').val(\''.$getTags->fields['tag'].'\');$(\'#list_'.$tid.'\').html(\'\').hide();">'.$tag.'</div>';

			$getTags->MoveNext();
		}
		$ajax->assign('list_'.$tid, 'innerHTML', $list);
		$ajax->assign('list_'.$tid, 'style.display', 'block');

	} else {
		$ajax->assign('list_'.$tid, 'innerHTML', '');
		$ajax->assign('list_'.$tid, 'style.display', 'none');
	}

	return $ajax;
}
?>